LCOV - code coverage report
Current view: top level - src/ev - task.c (source / functions) Hit Total Coverage
Test: Lely core libraries-2.4.0 Code Coverage Lines: 18 18 100.0 %
Date: 2024-09-12 13:53:33 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 6 6 100.0 %

           Branch data     Line data    Source code
       1                 :            : /**@file
       2                 :            :  * This file is part of the event library; it contains the implementation of the
       3                 :            :  * task functions.
       4                 :            :  *
       5                 :            :  * @see lely/ev/task.h
       6                 :            :  *
       7                 :            :  * @copyright 2018-2019 Lely Industries N.V.
       8                 :            :  *
       9                 :            :  * @author J. S. Seldenthuis <jseldenthuis@lely.com>
      10                 :            :  *
      11                 :            :  * Licensed under the Apache License, Version 2.0 (the "License");
      12                 :            :  * you may not use this file except in compliance with the License.
      13                 :            :  * You may obtain a copy of the License at
      14                 :            :  *
      15                 :            :  *     http://www.apache.org/licenses/LICENSE-2.0
      16                 :            :  *
      17                 :            :  * Unless required by applicable law or agreed to in writing, software
      18                 :            :  * distributed under the License is distributed on an "AS IS" BASIS,
      19                 :            :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      20                 :            :  * See the License for the specific language governing permissions and
      21                 :            :  * limitations under the License.
      22                 :            :  */
      23                 :            : 
      24                 :            : #include "ev.h"
      25                 :            : #include <lely/ev/exec.h>
      26                 :            : #include <lely/ev/task.h>
      27                 :            : #include <lely/util/util.h>
      28                 :            : 
      29                 :            : #include <stdint.h>
      30                 :            : 
      31                 :            : struct ev_task *
      32                 :   50348085 : ev_task_from_node(struct slnode *node)
      33                 :            : {
      34         [ +  + ]:   50348085 :         return node ? structof(node, struct ev_task, _node) : NULL;
      35                 :            : }
      36                 :            : 
      37                 :            : size_t
      38                 :         72 : ev_task_queue_post(struct sllist *queue)
      39                 :            : {
      40                 :         72 :         size_t n = 0;
      41                 :            : 
      42                 :            :         struct slnode *node;
      43         [ +  + ]:        107 :         while ((node = sllist_pop_front(queue))) {
      44                 :         35 :                 struct ev_task *task = ev_task_from_node(node);
      45                 :         35 :                 ev_exec_t *exec = task->exec;
      46                 :         35 :                 ev_exec_post(exec, task);
      47                 :         35 :                 ev_exec_on_task_fini(exec);
      48                 :         35 :                 n += n < SIZE_MAX;
      49                 :            :         }
      50                 :            : 
      51                 :         72 :         return n;
      52                 :            : }
      53                 :            : 
      54                 :            : size_t
      55                 :       1184 : ev_task_queue_abort(struct sllist *queue)
      56                 :            : {
      57                 :       1184 :         size_t n = 0;
      58                 :            : 
      59                 :            :         struct slnode *node;
      60         [ +  + ]:       2060 :         while ((node = sllist_pop_front(queue))) {
      61                 :        876 :                 struct ev_task *task = ev_task_from_node(node);
      62                 :        876 :                 ev_exec_on_task_fini(task->exec);
      63                 :        876 :                 n += n < SIZE_MAX;
      64                 :            :         }
      65                 :            : 
      66                 :       1184 :         return n;
      67                 :            : }

Generated by: LCOV version 1.14